home *** CD-ROM | disk | FTP | other *** search
/ Artworks - Keep it Simple 1 / Artworks - Keep it Simple 1.iso / pstudio / pstudio.ms_ / pstudio.ms
Encoding:
Text File  |  1994-08-19  |  13.9 KB  |  513 lines

  1. '**************************************************************************
  2. '*            for PhotoStudio Setup
  3. '**************************************************************************
  4.  
  5. '' no debug '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT      = 200
  12. CONST DESTPATH     = 300
  13. CONST EXITFAILURE  = 400
  14. CONST EXITQUIT     = 600
  15. CONST EXITSUCCESS  = 700
  16. CONST OPTIONS      = 800
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST APPFILES     = 1
  27. CONST OPTFILES1    = 2
  28. CONST OPTFILES2    = 3
  29.  
  30.  
  31. GLOBAL DEST$        ''Default destination directory.
  32. GLOBAL WINDRIVE$    ''Windows drive letter.
  33. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  34. GLOBAL OPT2OPT$     ''Option selection from OptFiles2 option dialog.
  35.  
  36. ''CustInst list symbol names
  37. GLOBAL APPNEEDS$    ''Option list costs per drive
  38. GLOBAL OPT1NEEDS$
  39. GLOBAL OPT2NEEDS$
  40. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  41. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  42.  
  43. ''Dialog list symbol names
  44. GLOBAL CHECKSTATES$
  45. GLOBAL STATUSTEXT$
  46. GLOBAL DRIVETEXT$
  47.  
  48.  
  49. DECLARE SUB AddOptFilesToCopyList (ftype%)
  50. DECLARE SUB RecalcOptFiles (ftype%)
  51. DECLARE SUB RecalcPath
  52. DECLARE SUB SetDriveStatus
  53. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  54.  
  55.  
  56.  
  57. INIT:
  58.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  59.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  60.  
  61.     SetBitmap CUIDLL$, LOGO
  62.     SetTitle "PhotoStudio Setup"
  63.  
  64.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  65.     IF szInf$ = "" THEN
  66.         szInf$ = GetSymbolValue("STF_CWDDIR") + "PSTUDIO.INF"
  67.     END IF
  68.     ReadInfFile szInf$
  69.  
  70.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  71.     DEST$ = WINDRIVE$ + ":\PSTUDIO"
  72.  
  73.     ''CustInst list symbols
  74.     CHECKSTATES$ = "CheckItemsState"
  75.     STATUSTEXT$  = "StatusItemsText"
  76.     DRIVETEXT$   = "DriveStatusText"
  77.     FOR i% = 1 TO 3 STEP 1
  78.         AddListItem CHECKSTATES$, "ON"
  79.     NEXT i%
  80.     FOR i% = 1 TO 3 STEP 1
  81.         AddListItem STATUSTEXT$, ""
  82.     NEXT i%
  83.     FOR i% = 1 TO 7 STEP 1
  84.         AddListItem DRIVETEXT$, ""
  85.     NEXT i%
  86.     ReplaceListItem DRIVETEXT$, 7, DEST$
  87.  
  88.     ''Disk cost list symbols
  89.     APPNEEDS$   = "AppNeeds"
  90.     OPT1NEEDS$  = "Opt1Needs"
  91.     OPT2NEEDS$  = "Opt2Needs"
  92.     EXTRACOSTS$ = "ExtraCosts"
  93.     BIGLIST$    = "BigList"
  94.     FOR i% = 1 TO 3 STEP 1
  95.         AddListItem BIGLIST$, ""
  96.     NEXT i%
  97.     FOR i% = 1 TO 26 STEP 1
  98.         AddListItem EXTRACOSTS$, "0"
  99.     NEXT i%
  100.  
  101.     ''File Option Variables
  102.     OPT1OPT$ = "1"
  103.     OPT2OPT$ = "1"
  104.  
  105.     RecalcPath
  106.     SetDriveStatus
  107.  
  108. '$IFDEF DEBUG
  109.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  110. '$ENDIF ''DEBUG
  111.  
  112.  
  113.  
  114. CUSTINST:
  115.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  116.  
  117.     IF sz$ = "CONTINUE" THEN
  118.         ''Install only if it will fit.
  119.         FOR i% = 1 TO 3 STEP 1
  120.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  121.                 GOSUB TOOBIG
  122.                 GOTO CUSTINST
  123.             END IF
  124.         NEXT i%
  125.         UIPop 1
  126.         GOTO INSTALL
  127.     ELSEIF sz$ = "PATH" THEN
  128.         GOTO GETPATH
  129.     ELSEIF sz$ = "CHK1" THEN
  130.         RecalcOptFiles APPFILES
  131.         SetDriveStatus
  132.         GOTO CUSTINST
  133.     ELSEIF sz$ = "CHK2" THEN
  134.         RecalcOptFiles OPTFILES1
  135.         SetDriveStatus
  136.         GOTO CUSTINST
  137.     ELSEIF sz$ = "CHK3" THEN
  138.         RecalcOptFiles OPTFILES2
  139.         SetDriveStatus
  140.         GOTO CUSTINST
  141.     ELSEIF sz$ = "BTN2" THEN
  142.         GOTO OPTFILES1
  143.     ELSEIF sz$ = "BTN3" THEN
  144.         GOTO OPTFILES2
  145.     ELSEIF sz$ = "REACTIVATE" THEN
  146.         RecalcPath
  147.         SetDriveStatus
  148.         GOTO CUSTINST
  149.     ELSE
  150.         GOSUB ASKQUIT
  151.         GOTO CUSTINST
  152.     END IF
  153.  
  154.  
  155.  
  156. INSTALL:
  157.     ClearCopyList
  158.     AddOptFilesToCopyList APPFILES
  159.     AddOptFilesToCopyList OPTFILES1
  160.     AddOptFilesToCopyList OPTFILES2
  161.     CreateDir DEST$, cmoNone
  162.     CopyFilesInCopyList
  163.  
  164. ''    IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  165. ''        ini$ = MakePath(DEST$, "DEMO.INI")
  166. ''        CreateIniKeyValue "WIN.INI", "MSSetup Sample 2", "Option1", OPT1OPT$, cmoNone
  167. ''        CreateIniKeyValue ini$, "Section 1", "Key 1", "Value 1" , cmoNone
  168. ''        CreateIniKeyValue ini$, "Section 2", "Key 2", "Value 2" , cmoNone
  169. ''        CreateIniKeyValue ini$, "Section 3", "Key 3", "Value 3" , cmoNone
  170. ''        ini$ = ""
  171. ''    END IF
  172. ''
  173. ''    IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  174.         CreateProgmanGroup "PhotoStudio", "", cmoNone
  175.         ShowProgmanGroup  "PhotoStudio", 1, cmoNone
  176.         CreateProgmanItem "PhotoStudio", "PhotoStudio", MakePath(DEST$,"pstudio.exe"), "", cmoOverwrite
  177.         CreateProgmanItem "PhotoStudio", "PhotoStudio Readme", "notepad.exe "+MakePath(DEST$,"readme.txt"), "", cmoOverwrite
  178.         CreateProgmanItem "PhotoStudio", "PhotoStudio Help", "winhelp.exe "+MakePath(DEST$,"pstudio.hlp"), "", cmoOverwrite
  179. ''    END IF
  180.  
  181.  
  182. QUIT:
  183.     ON ERROR GOTO ERRQUIT
  184.  
  185.     IF ERR = 0 THEN
  186.         dlg% = EXITSUCCESS
  187.     ELSEIF ERR = STFQUIT THEN
  188.         dlg% = EXITQUIT
  189.     ELSE
  190.         dlg% = EXITFAILURE
  191.     END IF
  192. QUITL1:
  193.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  194.     IF sz$ = "REACTIVATE" THEN
  195.         GOTO QUITL1
  196.     END IF
  197.     UIPop 1
  198.  
  199.     END
  200.  
  201. ERRQUIT:
  202.     i% = DoMsgBox("Setup sources were corrupted!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  203.     END
  204.  
  205.  
  206.  
  207. GETPATH:
  208.     SetSymbolValue "EditTextIn", DEST$
  209.     SetSymbolValue "EditFocus", "END"
  210. GETPATHL1:
  211.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  212.  
  213.     IF sz$ = "CONTINUE" THEN
  214.         olddest$ = DEST$
  215.         DEST$ = GetSymbolValue("EditTextOut")
  216.  
  217.         ''Validate new path.
  218.         IF IsDirWritable(DEST$) = 0 THEN
  219.             GOSUB BADPATH
  220.             GOTO GETPATHL1
  221.         END IF
  222.         UIPop 1
  223.  
  224.         ''Truncate display if too long.
  225.         IF LEN(DEST$) > 23 THEN
  226.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  227.         ELSE
  228.             ReplaceListItem DRIVETEXT$, 7, DEST$
  229.         END IF
  230.  
  231.         ''Recalc if path changed.
  232.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  233.             RecalcPath
  234.             SetDriveStatus
  235.         END IF
  236.  
  237.         olddest$ = ""
  238.         GOTO CUSTINST
  239.     ELSEIF sz$ = "REACTIVATE" THEN
  240.         RecalcPath
  241.         SetDriveStatus
  242.         GOTO GETPATHL1
  243.     ELSEIF sz$ = "EXIT" THEN
  244.         GOSUB ASKQUIT
  245.         GOTO GETPATHL1
  246.     ELSE
  247.         UIPop 1
  248.         GOTO CUSTINST
  249.     END IF
  250.  
  251.  
  252.  
  253. OPTFILES1:
  254.     SetSymbolValue "RadioDefault", OPT1OPT$
  255. OPT1L1:
  256.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  257.     newopt$ = GetSymbolValue("ButtonChecked")
  258.  
  259.     IF sz$ = "CONTINUE" THEN
  260.         UIPop 1
  261.         IF newopt$ <> OPT1OPT$ THEN
  262.             OPT1OPT$ = newopt$
  263.             RecalcOptFiles OPTFILES1
  264.             SetDriveStatus
  265.         END IF
  266.         newopt$ = ""
  267.         GOTO CUSTINST
  268.     ELSEIF sz$ = "REACTIVATE" THEN
  269.         RecalcPath
  270.         SetDriveStatus
  271.         GOTO OPT1L1
  272.     ELSEIF sz$ = "EXIT" THEN
  273.         GOSUB ASKQUIT
  274.         GOTO OPT1L1
  275.     ELSE
  276.         UIPop 1
  277.         newopt$ = ""
  278.         GOTO CUSTINST
  279.     END IF
  280.  
  281.  
  282.  
  283. OPTFILES2:
  284.     SetSymbolValue "RadioDefault", OPT2OPT$
  285. OPT2L1:
  286.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  287.     newopt$ = GetSymbolValue("ButtonChecked")
  288.  
  289.     IF sz$ = "CONTINUE" THEN
  290.         UIPop 1
  291.         IF newopt$ <> OPT2OPT$ THEN
  292.             OPT2OPT$ = newopt$
  293.             RecalcOptFiles OPTFILES2
  294.             SetDriveStatus
  295.         END IF
  296.         newopt$ = ""
  297.         GOTO CUSTINST
  298.     ELSEIF sz$ = "REACTIVATE" THEN
  299.         RecalcPath
  300.         SetDriveStatus
  301.         GOTO OPT2L1
  302.     ELSEIF sz$ = "EXIT" THEN
  303.         GOSUB ASKQUIT
  304.         GOTO OPT2L1
  305.     ELSE
  306.         UIPop 1
  307.         newopt$ = ""
  308.         GOTO CUSTINST
  309.     END IF
  310.  
  311.  
  312.  
  313. TOOBIG:
  314.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  315.     IF sz$ = "REACTIVATE" THEN
  316.         RecalcPath
  317.         SetDriveStatus
  318.         GOTO TOOBIG
  319.     END IF
  320.     UIPop 1
  321.     RETURN
  322.  
  323.  
  324.  
  325. BADPATH:
  326.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  327.     IF sz$ = "REACTIVATE" THEN
  328.         RecalcPath
  329.         SetDriveStatus
  330.         GOTO BADPATH
  331.     END IF
  332.     UIPop 1
  333.     RETURN
  334.  
  335.  
  336.  
  337. ASKQUIT:
  338.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  339.  
  340.     IF sz$ = "EXIT" THEN
  341.         UIPopAll
  342.         ERROR STFQUIT
  343.     ELSEIF sz$ = "REACTIVATE" THEN
  344.         GOTO ASKQUIT
  345.     ELSE
  346.         UIPop 1
  347.     END IF
  348.     RETURN
  349.  
  350.  
  351.  
  352. '**
  353. '** Purpose:
  354. '**     Adds the specified option files to the copy list.
  355. '** Arguments:
  356. '**     ftype%  - type of files to add, one of the following:
  357. '**             APPFILES, OPTFILES1, OPTFILES2
  358. '** Returns:
  359. '**     none.
  360. '*************************************************************************
  361. SUB AddOptFilesToCopyList (ftype%) STATIC
  362.  
  363.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  364.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  365.         IF ftype% = APPFILES THEN
  366.             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  367.         ELSEIF ftype% = OPTFILES1 THEN
  368.             AddSectionKeyFileToCopyList "OptFiles1", OPT1OPT$, SrcDir$, DEST$
  369.         ELSEIF ftype% = OPTFILES2 THEN
  370.             AddSectionKeyFileToCopyList "OptFiles2", OPT2OPT$, SrcDir$, DEST$
  371.         END IF
  372.         SrcDir$ = ""
  373.     END IF
  374. END SUB
  375.  
  376.  
  377. '**
  378. '** Purpose:
  379. '**     Recalculates disk space for the given option files and sets
  380. '**     the status info symbol "StatusItemsText".
  381. '** Arguments:
  382. '**     ftype% - type of files to add, one of the following:
  383. '**             APPFILES, OPTFILES1, OPTFILES2
  384. '** Returns:
  385. '**     none.
  386. '*************************************************************************
  387. SUB RecalcOptFiles (ftype%) STATIC
  388.     CursorSave% = ShowWaitCursor()
  389.     ClearCopyList
  390.     AddOptFilesToCopyList ftype%
  391.  
  392.     fExtra% = 0
  393.     IF ftype% = APPFILES THEN
  394.         ListSym$ = APPNEEDS$
  395. ''        IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  396. ''            ''Add extra cost to Windows drive for ini/progman, etc.
  397. ''            ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  398. ''            ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  399. ''            fExtra% = 1
  400. ''        END IF
  401.     ELSEIF ftype% = OPTFILES1 THEN
  402.         ListSym$ = OPT1NEEDS$
  403.     ELSEIF ftype% = OPTFILES2 THEN
  404.         ListSym$ = OPT2NEEDS$
  405.     END IF
  406.  
  407.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  408.  
  409.     cost& = 0
  410.     FOR i% = 1 TO 26 STEP 1
  411.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  412.     NEXT i%
  413.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  414.  
  415.     IF StillNeed& > 0 THEN
  416.         ReplaceListItem BIGLIST$, ftype%, "YES"
  417.     ELSE
  418.         ReplaceListItem BIGLIST$, ftype%, ""
  419.     END IF
  420.  
  421.     IF fExtra% THEN
  422.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  423.     END IF
  424.     RestoreCursor CursorSave%
  425.     ListSym$ = ""
  426. END SUB
  427.  
  428.  
  429. '**
  430. '** Purpose:
  431. '**     Recalculates disk space and sets option status info according
  432. '**     to the current destination path.
  433. '** Arguments:
  434. '**     none.
  435. '** Returns:
  436. '**     none.
  437. '*************************************************************************
  438. SUB RecalcPath STATIC
  439.  
  440.     CursorSave% = ShowWaitCursor()
  441.  
  442.     RecalcOptFiles APPFILES
  443.     RecalcOptFiles OPTFILES1
  444.     RecalcOptFiles OPTFILES2
  445.  
  446.     RestoreCursor CursorSave%
  447. END SUB
  448.  
  449.  
  450. '**
  451. '** Purpose:
  452. '**     Sets drive status info according to latest disk space calcs.
  453. '** Arguments:
  454. '**     none.
  455. '** Returns:
  456. '**     none.
  457. '*************************************************************************
  458. SUB SetDriveStatus STATIC
  459.  
  460.     drive$ = MID$(DEST$, 1, 1)
  461.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  462. ''   cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  463.     cost& = 3100
  464.     free& = GetFreeSpaceForDrive(drive$)
  465.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  466. ''    ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  467.     ReplaceListItem DRIVETEXT$, 2, STR$(cost&) + " K"
  468.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  469.  
  470. ''    IF drive$ = WINDRIVE$ THEN
  471. ''        ReplaceListItem DRIVETEXT$, 4, ""
  472. ''        ReplaceListItem DRIVETEXT$, 5, ""
  473. ''        ReplaceListItem DRIVETEXT$, 6, ""
  474. ''    ELSE
  475. ''        ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  476. ''        cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) + VAL(GetListItem(OPT2NEEDS$, ndrive%))
  477. ''        IF cost& = 0 THEN
  478. ''            ReplaceListItem DRIVETEXT$, 4, ""
  479. ''            ReplaceListItem DRIVETEXT$, 5, ""
  480. ''            ReplaceListItem DRIVETEXT$, 6, ""
  481. ''        ELSE
  482. ''            free& = GetFreeSpaceForDrive(WINDRIVE$)
  483. ''            ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  484. ''            ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  485. ''            ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  486. ''        END IF
  487. ''    END IF
  488. END SUB
  489.  
  490.  
  491. '**
  492. '** Purpose:
  493. '**     Appends a file name to the end of a directory path,
  494. '**     inserting a backslash character as needed.
  495. '** Arguments:
  496. '**     szDir$  - full directory path (with optional ending "\")
  497. '**     szFile$ - filename to append to directory
  498. '** Returns:
  499. '**     Resulting fully qualified path name.
  500. '*************************************************************************
  501. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  502.     IF szDir$ = "" THEN
  503.         MakePath = szFile$
  504.     ELSEIF szFile$ = "" THEN
  505.         MakePath = szDir$
  506.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  507.         MakePath = szDir$ + szFile$
  508.     ELSE
  509.         MakePath = szDir$ + "\" + szFile$
  510.     END IF
  511. END FUNCTION
  512.  
  513.